The present invention relates to garbage collection in virtual machine software and, in particular, to a generational garbage collector with a persistent object cache.
In computer systems, a virtual machine is software that mimics the performance of a hardware device. One example of a virtual machine is a program that allows applications written for xc3x9786 format microprocessor (e.g., available from Intel Corporation) to be run on a 68000 format microprocessor (e.g., available from Motorola Corporation). Virtual machine computers, referred to simply as virtual machines hereafter, have been developed recently to provide software that mimics a xe2x80x9ccompletexe2x80x9d computer. One example is the Java(trademark) virtual machine introduced by Sun Microsystems, Inc. and available for a variety of computer platforms to run programs written in the Java(trademark) virtual machine-based programming language. Such a virtual machine functions as a computer platform that hides the operating system of the underlying hardware computer from applets and applications written in the programming language of the virtual machine.
Virtual machines are commonly associated with stand-alone or client-side computers where the virtual machine operates in conjunction with an operating system or an Internet browser, for example. It will be appreciated, however, that virtual machines may also be operated in conjunction with or on a server computer that serves one or more client computers. The clients may be connected to the server directly or by networked connections. One example of a server virtual machine is the Gemstone/J(trademark) 1.0 server virtual machine available from Gemstone Systems, Inc. of Beaverton, Oreg., the assignee of the present invention. Server virtual machines may be used in a variety of applications, including database and transaction applications.
Some virtual machines support access to persistent objects that are stored on disk in a persistent store. Before the execution of a bytecode in such a virtual machine can read or write a field in a persistent object, the object must be copied into the virtual machine object memory so that the object can be assigned a memory address. The copy of the persistent object is then subject to normal garbage collection rules and movement in memory, as is known in the art.
Some prior virtual machine implementations include an object memory structure that includes a contiguous region of virtual address space in which objects (i.e., temporary objects) are segregated into a new generation space and an old generation space according to the ages of the objects. Objects are first allocated to the new generation space in a copy-on-read operation in which, for example, a temporary copy of a persistent object is copied from a persistent object stored in a persistent object memory, such as disk storage. In accordance with conventional generational garbage collection, surviving objects in the new generation space are promoted or copied to the old generation space.
Commonly, most of the copies of permanent objects in the new generation space will be deleted during a garbage collection because only a few of the objects are typically referenced or reachable from the virtual machine (e.g., Java) execution stack at any one time. This can cause the lifetime of objects in the new generation space to be quite brief and can require repeated copying of objects from a persistent store, thereby reducing performance.
To improve performance, an application program executing in a virtual machine needs to have a reasonable percentage of it""s working set of persistent objects available in memory, and in particular have copies of the persistent objects in the virtual machine object memory. Accordingly, the present invention includes an object memory structure that includes a contiguous region of virtual address space in which objects (i.e., temporary objects) are segregated into a new generation space and an old generation space according to the ages of the objects, as well as a permanent object memory (POM) generation space.
The POM generation space operates as a persistent object cache that is not subject to conventional garbage collection processes. This makes possible a very large POM generation space without a corresponding increase in the cost of garbage collection. By contrast, enlarging the old generation space could greatly increase the cost of garbage collection. Also, the lifetime of an object in the POM generation space relates to the frequency at which objects are copied from a persistent object store (e.g., disk storage) and shared object cache, rather than garbage collection processes relating to the new generation space and the old generation space. Whenever the POM generation space is full, live objects are copied from the POM generation space to the new generation space to make way for new temporary objects to be copied from the persistent object store or shared object cache. Once copied to the new generation space from the POM generation space, objects are subject to conventional garbage collection processing.
The lifetimes of objects in the POM generation space relate to the overall traffic of objects being copied from the persistent object memory rather than conventional garbage collection criteria. Objects that are recently copied from the persistent object memory are less likely to be garbage collected prematurely, as can frequently happen in conventional systems. Accordingly, performance can be improved for an application program executing in a virtual machine.
Additional objects and advantages of the present invention will be apparent from the detailed description of the preferred embodiment thereof, which proceeds with reference to the accompanying drawings.